{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "de3014a5",
   "metadata": {},
   "source": [
    "## 创建字典的三种常见方法\n",
    "\n",
    "1.直接按照字典的格式创建： {key1:value1,key2:value2...} \n",
    " \n",
    " 2.dict（）函数来创建字典 ： dict(key1=value1,key2=value2,...) \n",
    " \n",
    " 3.字典数据增加的方式： 新建空字典 dict_name = {} ,dict_name[key1] = value1 ..."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "81eb7132",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'stu_10001': 'Alex', 'stu_10002': 'Jack', 'stu_10003': 'Mary'}"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 1.直接按照字典的格式创建： {key1:value1,key2:value2...}\n",
    "stu_info = {\"stu_10001\":\"Alex\",\n",
    "            \"stu_10002\":\"Jack\",\n",
    "            \"stu_10003\":\"Mary\"}\n",
    "stu_info"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "3771112d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'stu_10001': 'Alex', 'stu_10002': 'Jack', 'stu_10003': 'Mary'}"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 2.dict（）函数来创建字典 ： dict(key1=value1,key2=value2,...)\n",
    "stu_info_2 = dict(stu_10001=\"Alex\",\n",
    "            stu_10002=\"Jack\",\n",
    "            stu_10003=\"Mary\")\n",
    "stu_info_2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "ddf06520",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'stu_10001': 'Alex', 'stu_10002': 'Jack', 'stu_10003': 'Mary'}"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 3.字典数据增加的方式： 新建空字典 dict_name = {} ,dict_name[key1] = value1 ...\n",
    "stu_info_3 = {}\n",
    "stu_info_3[\"stu_10001\"] = \"Alex\"\n",
    "stu_info_3[\"stu_10002\"] = \"Jack\"\n",
    "stu_info_3[\"stu_10003\"] = \"Mary\"\n",
    "stu_info_3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c12cb47b",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
